
public class Krug implements Comparable, Dogadjaj{
	
	private Tacka[] centarINajdonja;
	double poluprecnik;
	double y;
	
	public Krug(Tacka a, Tacka b, Tacka c){
		centarINajdonja = dajKrug(a, b, c);
	}
	
	public Tacka[] dajKrug(Tacka a, Tacka b, Tacka c){
		double k1, k2, n1, n2, normalnaK1, normalnaK2, normalnaN1, normalnaN2;
		k1 = (a.getY() - b.getY())/(a.getX()-b.getX());
		System.out.println("k1 : " + k1);
		n1 = (a.getY() - k1*a.getX());
		System.out.println("n1 : " + n1);
		k2 = (b.getY() - c.getY())/(b.getX()-c.getX());
		System.out.println("k2 : " + k2);
		n2 = (b.getY() - k2*b.getX());
		System.out.println("n2 : " + n2);
		
		normalnaK1 = (-1)/(k1);
		normalnaK2 = (-1)/(k2);
		System.out.println("normalnaK1 : " + normalnaK1);
		System.out.println("normalnaK2 : " + normalnaK2);
		
		Tacka pom1 = new Tacka((a.getX() + b.getX())/2, (a.getY() + b.getY())/2);
		Tacka pom2 = new Tacka((b.getX() + c.getX())/2, (b.getY() + c.getY())/2);
		normalnaN1 = (pom1.getY() - normalnaK1*pom1.getX());
		normalnaN2 = (pom2.getY() - normalnaK2*pom2.getX());
		/*tacke.add(new Tacka(2, normalnaK1*2+normalnaN1));
		tacke.add(new Tacka(500, normalnaK1*500+normalnaN1));
		
		tacke.add(new Tacka(2, normalnaK2*2+normalnaN2));
		tacke.add(new Tacka(500, normalnaK2*500+normalnaN2));*/
		System.out.println("normalnaN1 : " + normalnaN1);
		System.out.println("normalnaN2 : " + normalnaN2);
		
		Tacka[] obe = new Tacka[2];
		Tacka centarKruga = new Tacka(0, 0);
		centarKruga.setX((-normalnaN1+normalnaN2)/(normalnaK1-normalnaK2));
		centarKruga.setY(normalnaK1*centarKruga.getX()+normalnaN1);
		poluprecnik = centarKruga.distanceTo(a);
		y = centarKruga.getY() + poluprecnik;
		Tacka najdonja = new Tacka(centarKruga.getX(), poluprecnik);
		obe[0] = centarKruga;
		obe[1] = najdonja;
		return obe;
	}

	public double getPoluprecnik() {
		return poluprecnik;
	}

	public void setPoluprecnik(double poluprecnik) {
		this.poluprecnik = poluprecnik;
	}

	public Tacka[] getCentarINajdonja() {
		return centarINajdonja;
	}

	public void setCentarINajdonja(Tacka[] centarINajdonja) {
		this.centarINajdonja = centarINajdonja;
	}
	
	public Tacka getCentar(){
		return centarINajdonja[0];
	}
	
	public Tacka getNajdonja(){
		return centarINajdonja[1];
	}
	
	public int compareTo(Object t) {
		Krug pom = (Krug)t;
		if (y >= pom.getY()) return 1;
		if (y < pom.getY()) return -1;
		return 0;
	}

	public double getY() {
		return y;
	}

	public void setY(double y) {
		this.y = y;
	}
}
